import {Component, OnInit} from '@angular/core';
import {NavController} from 'ionic-angular';

import {PassCountPage} from './bypassCount/passCount';
import {PersonalDataPage} from '../personalData/personalData';
import {ModifyPswPage} from '../modifyPsw/modifyPsw';
import {LoginPage} from "../login/login";
import {services} from "../../providers/service";
import {PersonalService} from "./person.service";

@Component({
    selector: 'page-person',
    templateUrl: 'person.html',
    providers: [PersonalService]
})
export class PersonPage implements OnInit {

    phone = "18062036201";
    personalDetial = [];

    constructor(public navCtrl: NavController,
                public service: services,
                public personalService: PersonalService,
    ) {
    }

    ngOnInit() {
        this.service.phone = this.phone;
        this.personalService.getPersonalData()
            .then(data => {
                if (data[0].resultStatus == 'success') {
                    this.personalDetial = data[0].infoData;
                    this.service.personalDetail = data[0].infoData;
                }

            }, err => {

            })
            .catch(fail => {

            })
    }

    goCount() {
        this.navCtrl.push(PassCountPage);
    }

    goPersonalData() {
        this.navCtrl.push(PersonalDataPage);
    }

    goModifyPsw() {
        this.navCtrl.push(ModifyPswPage);
    }

    //退出登录
    goLogin() {
        this.navCtrl.goToRoot(LoginPage);
    }
}